local skill = fk.CreateSkill {
  name = "iberia_fire__slash_skill",
}

Fk:loadTranslationTable{ ["iberia_fire__slash"] = "火杀" }

local I = require "packages/iberia/utility"

local slash_skill = Fk.skills["slash_skill"] --[[ @as ActiveSkill ]]

skill:addEffect("cardskill", {
  prompt = function(self, player, selected_cards)
    local card = Fk:cloneCard("iberia_fire__slash")
    card:addSubcards(selected_cards)
    local max_num = self:getMaxTargetNum(player)
    if max_num > 1 then
      local num = #table.filter(Fk:currentRoom().alive_players, function (p)
        return p ~= player and not player:isProhibited(p, card)
      end)
      max_num = math.min(num, max_num)
    end
    return max_num > 1 and "#fire__slash_skill_multi:::" .. max_num or "#fire__slash_skill"
  end,
  max_phase_use_time = 1,
  target_num = 1,
  can_use = slash_skill.canUse,
  mod_target_filter = slash_skill.modTargetFilter,
  target_filter = slash_skill.targetFilter,
  on_effect = function(self, room, effect)
    room:damage({
      from = effect.from,
      to = effect.to,
      card = effect.card,
      damage = 1,
      damageType = fk.FireDamage,
      skillName = "iberia_fire__slash",
    })
    if I.isRepeller(effect.from) and not effect.to:isKongcheng() then
      local card = room:askToChooseCard(effect.from, {
        target = effect.to,
        flag = "he",
        skill_name = "iberia_fire__slash",
        prompt = "#iberia_fire__slash_skill-discard",
      })
      room:throwCard(card, "iberia_fire__slash", effect.to, effect.from)
    end
  end,
})

return skill
